#include <QApplication>
#include <QScreen>
#include <QGuiApplication>
#include <QPixmap>
#include <QDateTime>
#include <QDebug>

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);

    // 自动生成截图名称
    QString screenshotName = QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss") + ".png";

    // 获取当前屏幕截图
    QScreen *screen = QGuiApplication::primaryScreen();
    if (screen) {
        QPixmap pixmap = screen->grabWindow(0);
        if (pixmap.save(screenshotName)) {
            qDebug() << "Screenshot saved as:" << screenshotName;
        } else {
            qWarning() << "Failed to save the screenshot.";
        }
    } else {
        qWarning() << "No screen detected.";
    }

    return 0; // 退出程序
}
